package android.alliance.ads.helper;

import android.app.Activity;
import android.content.Context;
import android.content.res.Configuration;
import android.util.DisplayMetrics;
import android.view.Display;
import android.view.WindowManager;

/**
 * Android Alliance - Ads-Library
 *
 * Copyright (c) 2011-2014 Android Alliance
 *
 * http://www.android-alliance.org
 * http://www.droidspirit.com
 * http://www.strangeoptics.com
 * 
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use 
 * this file except in compliance with the License. You may obtain a copy of the License at  
 * 
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and 
 * limitations under the License.
 * 
 *  E-Mail: support@droidspirit.com
 */
public class ScreenSizeHelper {

	private static ScreenSizeHelper instance;
	private Integer height = null;
	private Integer width = null;
	
	
	public static ScreenSizeHelper getInstance(){
		if(instance == null){
			instance = new ScreenSizeHelper();
		}
		
		return instance;
	}
	
	private void init(Context context){
			
		if(width == null || height == null){
			DisplayMetrics metrics = context.getResources().getDisplayMetrics();
			
			if(android.os.Build.VERSION.SDK_INT > 14){
				
				// do get real size
			} else {
				
				width = metrics.widthPixels;
				height = metrics.heightPixels;

			}
			
			// das hier dann raus
			width = metrics.widthPixels;
			height = metrics.heightPixels;
			
		}
	}
	
	public int getDisplayHeight(Context context){
		init(context);
		return height;
	}
	
	
	public int getDisplayWidth(Context context){
		init(context);
		
		return width;
	}
	
	public int getDisplayLongerSize(Context context){
		init(context);
		
		if(width > height){
			return width;
		} else {
			return height;
		}
	}
}
